#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// 3169. 无需开会的工作日
// https://leetcode.cn/problems/count-days-without-meetings/description/?envType=daily-question&envId=2025-07-11

class Solution {
public:
    int countDays(int days, vector<vector<int>>& meetings) {
        sort(meetings.begin(), meetings.end());
        int n = meetings.size();
        int pre = 1;
        int ans = 0;
        for (int i = 0; i < n ; i++)
        {
            if(meetings[i][0] > pre ){
                ans += meetings[i][0] - pre - 1;
            }
            pre = max(pre, meetings[i][1]);
        }
        if(days > meetings[n-1][1]){
            ans += days - meetings[n-1][1];
        }
        return ans;
    }
};

int main()
{
    return 0;
}